package com.yinshu.teleshield.controller;

import com.yinshu.teleshield.domain.entity.UserEntity;
import com.yinshu.teleshield.domain.vo.user.UserUpdateVO;
import com.yinshu.teleshield.service.UserService;
import com.yinshu.teleshield.tkbase.base.R;
import com.yinshu.teleshield.utils.CommonBeanUtils;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 用户表(User)表控制层
 *
 * @author yangjunxiong   2024-11-11 11:22:22
 */
@Tag(name = "用户表 (User)")
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("teleshield/user")
public class UserController {
    private final UserService userService;

    @Operation(summary = "修改", description = "修改UpdateVO中不为空的字段")
    @PutMapping
    public R<UserEntity> update(@RequestBody @Validated UserUpdateVO updateVO) {
        log.info("{}.update.修改,请求参数:updateVO:{}", this.getClass().getName(), CommonBeanUtils.toJSONString(updateVO));
        UserEntity userEntity = userService.updateById(updateVO);
        return R.success(userEntity);
    }
}
